<template>
  <transition name="fade">
    <div v-if="show" class="global-dialog">
      <div class="header">
        <div class="title">上传进度</div>
        <div class="kuzhan" @click="isSpread = !isSpread">
          <el-icon v-if="!isSpread"><ArrowUpBold /></el-icon>
          <el-icon v-if="isSpread"><ArrowDownBold /></el-icon>
        </div>
        <div class="close" @click="handleColse">
          <el-icon><CloseBold /></el-icon>
        </div>
      </div>
      <div class="content" v-if="isSpread">
        <div class="list">
          <div class="item" v-for="(item, key) in uploadInfo" :key="key">
            <div class="upload-item-avatar">
              <img
                v-if="item.fileType === '2'"
                src=""
                alt="视频"
              />
              <img
                v-if="item.fileType === '3'"
                src=""
                alt="音频"
              />
              <img
                v-if="item.fileType === '1'"
                src=""
                alt="图片"
              />
            </div>
            <div class="upload-item-body">
              <span class="upload-item-body-filename">
                <el-tooltip placement="top" effect="light">
                  <template #content>
                    <p style="width: 150px">{{ item.name }}</p>
                  </template>
                  <span class="tip3000">{{ item.name }}</span>
                </el-tooltip>
              </span>
              <span class="upload-item-complete">
                <el-progress
                  v-if="item.uploading && !item.transcoding"
                  :percentage="item.uploadProgress"
                  style="width: 100%"
                />
                <el-button
                  v-if="item.transcoding && !item.transcoded"
                  type="primary"
                  text
                  loading
                >
                  正在转码
                </el-button>
                <span class="uploadsuccess" v-if="item.transcoded">
                  <img
                    src=""
                    class="upload-item-complete-icon"
                  />
                  <span>上传成功</span>
                </span>
              </span>
            </div>
            <!-- <div class="upload-item-right">
              <span> 查看 </span>
            </div> -->
          </div>

          <!-- <div class="item">
            <div class="upload-item-avatar">
              <img
                src=""
                alt=""
              />
            </div>
            <div class="upload-item-body">
              <span class="upload-item-body-filename">
                <el-tooltip placement="top" effect="light">
                  <template #content>
                    <p style="width: 150px">N2ZyB3aWR0aD0iMzYiIGhlaWdodD0iMzYiIHZpZXdCb3g9IjAgMCA</p>
                  </template>
                  <span class="tip3000"> N2ZyB3aWR0aD0iMzYiIGhlaWdodD0iMzYiIHZpZXdCb3g9IjAgMCA </span>
                </el-tooltip>
              </span>
              <span class="upload-item-complete">
                <el-progress :percentage="70" style="width: 100%" />
                <el-button type="primary" text loading>正在转码</el-button>
                <span class="uploadsuccess">
                  <img
                    src=""
                    class="upload-item-complete-icon"
                  />
                  <span> 上传成功 </span>
                </span>
              </span>
            </div>
            <div class="upload-item-right">
              <span> 查看 </span>
            </div>
          </div> -->
          <!-- item-end -->
        </div>
      </div>
    </div>
  </transition>
</template>

<script setup lang="ts">
import { ref, toRefs } from 'vue'

import { useGlobalUploadDialogStore } from '@/store'

const globalUploadDialogStore = useGlobalUploadDialogStore()

const { show, uploadInfo } = toRefs(globalUploadDialogStore)

const isSpread = ref(true)

const handleColse = () => {
  globalUploadDialogStore.hideDialog()
}
</script>

<style scoped lang="scss">
/* Your dialog styles here */
.global-dialog {
  /* Styles for the dialog overlay */
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2222;

  max-width: 350px;
  width: 100%;
  background-color: var(--el-bg-color);
  border-radius: var(--el-messagebox-border-radius);
  border: 1px solid var(--el-border-color-lighter);
  font-size: var(--el-messagebox-font-size);
  box-shadow: var(--el-box-shadow-light);
  text-align: left;
  backface-visibility: hidden;
  box-sizing: border-box;
  .content {
    width: 100%;
    max-height: 500px;
    min-height: 90px;
    overflow: auto;
    box-sizing: border-box;
    padding: 5px 20px;
    .list {
      width: 100%;
      box-sizing: border-box;
      .item {
        align-items: center;
        box-sizing: border-box;
        display: flex;
        padding: 8px 0;

        .upload-item-avatar {
          border-radius: 3px;
          height: 60px;
          overflow: hidden;
          width: 60px;
          img {
            height: 100%;
            object-fit: cover;
            width: 100%;
          }
        }
        .upload-item-body {
          display: flex;
          flex: 1 0;
          flex-flow: column;
          font-size: 14px;
          font-style: normal;
          font-weight: 600;
          justify-content: center;
          line-height: 25px;
          margin-left: 8px;
          .upload-item-body-filename {
            overflow: hidden;
            max-width: 180px;
            display: block;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-size: 14px;
            font-weight: 400;
            color: #1f2338;
            .tip3000 {
              overflow: hidden;
              max-width: 180px;
              display: block;
              text-overflow: ellipsis;
              white-space: nowrap;
              font-size: 14px;
              font-weight: 400;
              color: #1f2338;
            }
          }
          .upload-item-complete {
            align-items: center;
            display: flex;
            height: 32px;
            line-height: 32px;
            .uploadsuccess {
              display: flex;
              align-items: center;
              img {
                margin-right: 3px;
              }
            }
          }
        }
        .upload-item-right {
          align-items: center;
          display: flex;
          justify-content: center;
        }
      }
    }
  }
  .header {
    line-height: 32px;
    display: flex;
    flex-direction: row;
    padding: 20px;
    box-sizing: border-box;
    .title {
      flex: 1;
      font-size: 16px;
      color: var(--e04a4d90-normalText);
    }
    .close {
      width: 32px;
      height: 32px;
      flex: 0 0 32px;
      text-align: center;
      cursor: pointer;
    }
    .kuzhan {
      width: 32px;
      height: 32px;
      flex: 0 0 32px;
      text-align: center;
      cursor: pointer;
    }
  }
}
</style>
